package com.wc.AlgoOJ._数学.素数判定2_3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/4 20:11
 * @description http://43.138.190.70:8888/p/MA0002
 * http://43.138.190.70:8888/p/MA0003
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = (int) 1e7 + 10;
    static int[] primes = new int[N];
    static boolean[] st = new boolean[N];
    static int cnt = 0;
    static long n;

    public static void main(String[] args) {
        ola();
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextLong();
            boolean ans = true;
            if (n < N) ans = !st[(int) n];
            else {
                for (int i = 0; i < cnt && primes[i] <= n / primes[i] ; i++) {
                    if (n % primes[i] == 0) {
                        ans = false;
                        break;
                    }
                }
            }
            if (ans) out.println("Yes");
            else out.println("No");
        }
        out.flush();
    }

    static void ola() {
        st[0] = st[1] = true;
        for (int i = 2; i < N; i++) {
            if (!st[i]) primes[cnt++] = i;
            for (int j = 0; i <= (N - 1) / primes[j]; j++) {
                st[i * primes[j]] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
